package work20240725;

import java.util.function.Function;
import java.util.stream.Collectors;

public class function4 {
    public static void main(String[] args) {
        encryptString("YUANzhi1987");
    }
    public static void encryptString(String s) {
        StringBuffer str = new StringBuffer(
                s.chars()
                        .mapToObj(c -> (char)c)
                        .map(function4::encryptChar)
                        .collect(Collectors.joining())
        );
        System.out.println(str.toString());
    }
    private static String encryptChar(char c) {
        if (c >= 'A' && c <= 'Z') {
            c = (char) (c + 32); // Convert to lowercase
            return String.valueOf(c < 'z' ? (char) (c + 1) : c);
        } else if (c >= 'a' && c <= 'z') {
            if (c >= 'a' && c <= 'c') return "2";
            if (c >= 'd' && c <= 'f') return "3";
            if (c >= 'g' && c <= 'i') return "4";
            if (c >= 'j' && c <= 'l') return "5";
            if (c >= 'm' && c <= 'o') return "6";
            if (c >= 'p' && c <= 's') return "7";
            if (c >= 't' && c <= 'v') return "8";
            if (c >= 'w' && c <= 'z') return "9";
        } else if (c >= '0' && c <= '9') {
            return String.valueOf(c);
        }
        return "";
    }
}
